from fastapi import Depends
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials

from service_impl.sys.user_service_impl import decode_token

security = HTTPBearer()


def verify_token(credentials: HTTPAuthorizationCredentials = Depends(security)):
    token = credentials.credentials
    payload = decode_token(token)
    return payload


require_auth = Depends(verify_token)
